<?php
$con = mysql_connect("localhost", "root", "");
if (!$con) {
    die('Could not connect: ' . mysql_error());
}

// Create table in my_db database
mysql_select_db("my_db", $con);

$username = $_POST["TxtName"];
$pwd = $_POST["TxtPassword"];

$sql = "SELECT * FROM `Admin` WHERE `UserName`= '$username' AND `Password`='$pwd';";
$result = mysql_query($sql);
if (mysql_num_rows($result) == 0) {
    header("location:login.php");

} else {
    session_start();
    $_SESSION["CheckedName"] = $username;
    $_SESSION["CheckTime"] = time();
    $_SESSION["login"] = "ok";
    header("location: index.php");
}
mysql_close($con);
?>